home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_ImportInt / DrawingViewWraps.psw < prev    next >
Encoding:
Text File  |  1992-12-19  |  4.0 KB  |  163 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34.  *    DrawingViewWraps.psw
  35.  *
  36.  *    Version:    2.0
  37.  *    Author:    Ken Fromm
  38.  *    History:
  39.  *            03-07-91        Added this comment.
  40.  */
  41.  
  42. defineps PSWStrokeX(float LLX, LLY, URX, URY)
  43.     LLX LLY moveto  URX URY lineto
  44.     LLX URY moveto URX  LLY lineto stroke
  45. endps
  46.  
  47. defineps PSWTranslateRotate(float X, Y, Angle)
  48.     X Y translate Angle rotate
  49. endps
  50.  
  51. defineps PSWSetLine (float Width, Gray)
  52.     Width setlinewidth Gray setgray
  53. endps
  54.  
  55. defineps PSWSetControlPoints (char *Font; float  FontSize, FontGray, FontWidth)
  56.     /Font FontSize selectfont  FontGray setgray  FontWidth setlinewidth
  57. endps
  58.  
  59. defineps PSWDrawControlPoints (float X, Y; float Pts[Tot_Pts]; int Tot_Pts; char *Chs)
  60.     X Y moveto  (Chs) Pts xyshow
  61. endps
  62.  
  63. /*
  64. *  The sa and rsa procedures ensure that the first character is drawn correctly
  65. *  with respect to device space. It's not so much an issue with square 
  66. *  images but can be quite significant with other shapes.
  67. */
  68. defineps PSWDefineFont(char *fontname)
  69.     10 dict dup begin
  70.     /sa { % x y  sa  x' y'
  71.         transform
  72.         0.25 sub round 0.25 add exch
  73.         0.25 sub round 0.25 add exch
  74.         itransform
  75.     } bind def
  76.  
  77.     /rsa { %dx dy  rsa  dx' dy'
  78.         dtransform
  79.         round exch
  80.         round exch
  81.         idtransform
  82.     } bind def
  83.  
  84.     /FontName /fontname def
  85.     /FontType 3 def
  86.     /FontMatrix [.001 0 0 .001 0 0] def
  87.     /FontBBox [-500 -500 500 500] def
  88.  
  89.     /Encoding 256 array def
  90.         0 1 255 {Encoding exch /.notdef put} for
  91.     
  92.     Encoding
  93.         dup (a) 0 get /Rectfill put
  94.         dup (b) 0 get /Rectopen put
  95.         dup (c) 0 get /CrossOut put
  96.         (d) 0 get /CrossIn put
  97.     
  98.     /CharProcs 5 dict def
  99.     CharProcs begin
  100.         /.notdef { } def
  101.         /Rectfill
  102.         {
  103.             -300 -300 sa moveto 0 600 rsa rlineto
  104.             600 0 rsa rlineto 0 -600 rsa rlineto closepath
  105.             fill
  106.         } def
  107.         /Rectopen
  108.         {
  109.             -300 -300 sa moveto 0 600 rsa rlineto
  110.             600 0 rsa rlineto 0 -600 rsa rlineto closepath
  111.             stroke
  112.         } def
  113.         /CrossOut
  114.         {
  115.             100 600 sa moveto     0 -1200 rsa rlineto
  116.             -200 0 rsa rlineto        0 1200 rsa rlineto closepath
  117.  
  118.             600 100 sa moveto        0 -200 rsa rlineto
  119.             -1200 0 rsa rlineto        0 200 rsa rlineto closepath
  120.             fill
  121.         } def
  122.         /CrossIn
  123.         {
  124.             0 500 sa moveto     0 -1000 rsa rlineto
  125.             -500 0 sa moveto    1000 0 rsa rlineto
  126.             stroke
  127.         } def
  128.     end
  129.     
  130.     /BuildChar
  131.     {
  132.         500 0 -500 -500 500 500 setcachedevice
  133.         exch begin
  134.             Encoding exch get
  135.             CharProcs exch get
  136.             exec
  137.         end
  138.     } def
  139.   end
  140.   
  141.   /fontname exch definefont pop
  142. endps
  143.  
  144. /*
  145. *    Define the image dictionary. Base it off of the NeXTLaser-300
  146. *    dictionary only give it a different transfer function.
  147. */
  148. defineps PSWDefineImageDict(char *dictname)
  149.    7 dict dup begin
  150.     /jobTag 0 def
  151.     /colorSpace 0 def
  152.     /defaultHalftone nextdict /NeXTMegaPixelDisplay get /defaultHalftone get  def
  153.     /samplesPerPixel 1 def
  154.     /bitsPerSample 1 def
  155.     /initialTransfer {} def
  156.     /isPlanar false def
  157.   end
  158.   
  159.   /dictname exch readonly def
  160. endps
  161.  
  162.  
  163.